<?php

namespace app\admin\controller;

use app\admin\BaseController;
use app\admin\model\NongyeTotalModel;

class AgricultureTotal extends BaseController
{
    public function query()
    {
        $nongyeTotalModel = NongyeTotalModel::where('village_id',$this->villageId)->find();
        return show($nongyeTotalModel);
    }

    public function edit()
    {
        $params = $this->request->param();
        $nongyeTotalModel = NongyeTotalModel::where('village_id',$this->villageId)->find();

        if ($nongyeTotalModel === null) {
            $params['village_id'] = $this->villageId;
            NongyeTotalModel::create($params);
        } else {
            $nongyeTotalModel->zyhzsjjtnc = $params['zyhzsjjtnc'];
            $nongyeTotalModel->ngqy = $params['ngqy'];
            $nongyeTotalModel->zcnysb = $params['zcnysb'];
            $nongyeTotalModel->zydh = $params['zydh'];
            $nongyeTotalModel->save();
        }

        return show();
    }

}